<?php 
class marketing_model extends CI_model{

	function get_id_global($id_m){
		$q = $this->db->query("SELECT id_global
							   FROM users
							   WHERE id=$id_m");
		$ret = $q->result();
		return $ret[0]->id_global;
	}

	function list_penugasan_marketing($id_g){
		$q = $this->db->query("SELECT *, pm.id_perusahaan as pmid_perusahaan, pm.id_marketer as pmid_marketer
							   FROM penugasan_marketing pm
							   JOIN 
							   perusahaan p ON pm.id_perusahaan=p.id_perusahaan
							   WHERE pm.id_marketer=$id_g AND pm.deskripsi_hasil_marketing IS NULL
							   ORDER BY pm.id_penugasan_marketing DESC");
		return $q->result();
	}


	function isi_penugasan_marketing($id){
		$q = $this->db->query("SELECT *, pm.id_perusahaan as pmid_perusahaan, pm.id_marketer as pmid_marketer
							   FROM penugasan_marketing pm
							   JOIN 
							   perusahaan p ON pm.id_perusahaan=p.id_perusahaan
							   JOIN 
							   marketer m ON pm.id_marketer=m.id_marketer
							   WHERE pm.id_penugasan_marketing=$id");
		return $q->result();
	}
	
}
?>